package com.example.es.springbootes.controller;

import com.example.es.springbootes.entity.Product;
import com.example.es.springbootes.utils.EsHlUtils;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/es/")
public class ProductSearchController {

    @Autowired
    private EsHlUtils esHlUtils;

    @GetMapping("search")
    public PageInfo<Product> search(String searchValue) {
        PageInfo search = esHlUtils.search(Product.class, 1, 3, "desc", "id", null, searchValue, "name", "desc");
        return search;
    }
}
